#pragma once

namespace RoomFW {

class TimeValue
{
public:
	TimeValue(int32_t seconds = 0, int32_t nanoSeconds = 0);

	void set(int32_t seconds = 0, int32_t nanoSeconds = 0);
	void setMilliseconds(int32_t ms);
	int32_t seconds(void) const;
	int32_t nanoSeconds(void) const;
	int32_t milliseconds(void) const;

	bool operator==(const TimeValue& rhs) const;
	bool operator!=(const TimeValue& rhs) const;
	bool operator>(const TimeValue& rhs) const;
	bool operator>=(const TimeValue& rhs) const;
	bool operator<(const TimeValue& rhs) const;
	bool operator<=(const TimeValue& rhs) const;

	TimeValue operator+(const TimeValue& rhs) const;
	TimeValue operator-(const TimeValue& rhs) const;

	TimeValue& operator+=(const TimeValue& rhs);
	TimeValue& operator-=(const TimeValue& rhs);

private:
	static const int32_t NanoSeconds = 1000000000;
	static const int32_t MilliSeconds = 1000;

	static void add(int32_t s1, int32_t n1, int32_t s2, int32_t n2, int32_t& sr, int32_t& nr);
	static void subtract(int32_t s1, int32_t n1, int32_t s2, int32_t n2, int32_t& sr, int32_t& nr);

	int32_t seconds_;
	int32_t nanoSeconds_;
};


}
